#include <iostream>

using namespace std;

struct Node
{
    char c;
    Node* pLeft;
    Node* pRight;
};

Node Tree[50];

int iNum;

Node* Create()
{
    Tree[iNum].pLeft = Tree[iNum].pRight = NULL;
    return &Tree[iNum++];
}

char str1[30],str2[30];

void postOrder(Node* pHead)
{
    if (pHead->pLeft != NULL)
    {
        postOrder(pHead->pLeft);
    }
    if (pHead->pRight != NULL)
    {
        postOrder(pHead->pRight);
    }

    cout << pHead->c << " ";
}

Node* build(int s1, int e1, int s2, int e2)
{
    Node* ret = Create();
    ret->c = str1[s1];

    int rootIdx = 0;
    for (int i = s2; i <= e2; ++i)
    {
        if (str2[i] == str1[s1])
        {
            rootIdx = i;
            break;
        }
    }

    if (rootIdx != s2)
    {
        ret->pLeft = build(s1+1, s1+(rootIdx-s2), s2, rootIdx-1);
    }

    if (rootIdx != e2)
    {
        ret->pRight = build(s1+1+(rootIdx-s2), e1, rootIdx+1, e2);
    }

    return ret;
}

int main()
{
    return 0;
}
